<!DOCTYPE html>
<html xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-for="http://www.w3.org/1999/xhtml"
      xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>事件处理</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
<div id="app">
    <div>{{counter}}--要+{{val}}</div>
    <input type="button" value="自增" v-on:click="increase()">
    <!--<input type="text" value="回车也可提交" v-on:keydown.enter="submit">-->
    <input type="text" value="回车也可提交" @keydown.ctrl.13="submit">
    <!--事件在methods里面也可以不写-->
    <!--不传递参数的话会传入一个undefined-->
</div>


</body>


<script>
        var app = new Vue({
        el: '#app',
        data: {
            books: [],
            counter: 0,
            val:0

        },
        methods:{

            submit() {
                alert("hhh")
            },
            increase(val) {
                this.counter=this.counter+2;
                this.val=val;
                console.log(val)

            }
        }
    })

</script>
</html>
